package com.bestv;
import com.bestv.task.UpdateInfoTask;
import com.bestv.task.UpdateTopKeywordTask;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by charle-chen on 15/11/26.
 */
public class Main {

    public static void main(String [] args){
        int inputNum = 0;

        try {
            System.out.println("1:更新top_keyword表中count值为0");
            System.out.println("2:删除top_keyword表中count值为0的数据");
            System.out.println("3:更新info表中生效而在vis中失效的数据");

            BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
            System.out.print("请输入对应操作前的数字：");
            String str = strin.readLine();
            Pattern pattern = Pattern.compile("^[0-9]+");
            Matcher matcher = pattern.matcher(str);
            if(matcher.matches()){
                inputNum  = Integer.parseInt(str);
            }else {
                System.out.println("请确认是否输入的是数字，谢谢~");
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

        switch (inputNum){
            case 1:
                UpdateTopKeywordTask updateTopKeywordTask = new UpdateTopKeywordTask();
                updateTopKeywordTask.backUpTopkeyword();
                updateTopKeywordTask.updateTopkeyword();
                break;
            case 2:
                UpdateTopKeywordTask updateTopKeywordTask1 = new UpdateTopKeywordTask();
                updateTopKeywordTask1.deleteTopkeyword();
                break;
            case 3:
                UpdateInfoTask updateInfoTask = new UpdateInfoTask();
                updateInfoTask.updateInfo();
                break;
            default:
                System.out.println("输入参数有误");
                break;
        }

    }
}
